package com.shujia.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo11Union {
  def main(args: Array[String]): Unit = {
    // 构建Spark上下文环境
    val conf: SparkConf = new SparkConf()
    conf.setAppName("Demo11Union")
    conf.setMaster("local")
    val sc: SparkContext = new SparkContext(conf)


    // 通过集合创建RDD
    val rdd1: RDD[Int] = sc.parallelize(List(1, 2, 3, 4, 5, 6))
    val rdd2: RDD[Int] = sc.parallelize(List(7, 8, 9))

    // 两个RDD union必须格式一样
    rdd1.union(rdd2).foreach(println)


  }

}
